******************************************************************************
* 2020 REPLICATION (2020-12-17)
*
*  + update encoding do-script from "ISO-8859-1" to "utf-8"
*  + specify Stata version
*  + all Stata results into one "output" folder
*  + install dependencies (outreg fitstat spost9)
*  + Note: some issues with spost9 ("prchange" and "prtab", commented out)

version 9
// ssc install outreg
// ssc install fitstat
// net describe spost9_ado, from(https://jslsoc.sitehost.iu.edu/stata)


******************************************************************************
* ANALYSIS OF FORMER POSITIONS OF EUROPEAN COMMISSIONERS
*   Holger Döring
*   Max-Planck-Institut für Gesellschaftsforschung
*   Paulstr. 3
*   50676 Köln
*   doering@mpi-fg-koeln.mpg.de
*   phone: +49/2 21/27 67 210
*
*   VERSION 0.41
*   Last modified
*   December 6th, 2006
******************************************************************************
*
*   for variables used in the data set, see 
*   'Codebook European Commissioner' by Holger Doering
*   short explanations of the variables are included into this do file
*
******************************************************************************


******************************************************************************
* GETTING STARTED
******************************************************************************

*** OPEN LOG FILE AND REPLACE OLD FILE
capture log close
log using output/commissioners-log.txt, replace text

*** MEMORY SETTINGS
clear
set mem 10m

*** MAKE EVERYTHING RUSH THROUGH AT ONCE (NO SPACE BAR NEEDED)
set more off

*** MAKE DATA DIRECTORY WORKING DIRECTORY (WORKS ONLY ON MY MPI PC)
capture cd "\\\atlas\home\DG\My Documents\research\commission\stats\stata\"

*** OPEN DATA FILE
use commissioners-2.0.dta, clear


******************************************************************************
* VARIABLES 
******************************************************************************
/* 
 posscore = scale based indicator for portfolio salience 
                   based on Druckman/Warwick 2005
                   average minister is assigned a value of 1.0
                   range from 0.2 for unelected positions 
		   and around 2.2 for prime minister
                   other values (average):
		      mp (0.33)
		      junior minister (0.7)
		      finance (1.9)
 partygov = categorical variable indicating commissioners party affilliation
                   0 = governing party
                   1 = opposition party
                   2 = no party affilliation 
 time      =  years after first commission took office in 1958
 incumbent =  was commissioner member of the commission before 
 oneseat  =  member state has only one seat in the commission
 elected   =  has the commissioner held a political position before
*/

*** ADD VARIABLE TO TO KEEP CONSTANT IN REGRESSION LOW
capture drop time
gen time = year - 1958

*** LABELING NON-CONTINIOUS VARIABLES
label define partygov 0 "governing party" 1 "opposition party" 2 "no party affilliation"
label define incumbent 0 "new Commissioner" 1 "incumbent"
label define elected 0 "bureaucrat" 1 "political position" 
label define oneseat 0 "two seats" 1 "one seat"

*** DROP MISSING OBSERVATIONS (SEE CODEBOOK)
drop if name=="Balazs" | name=="Kalniete" | name=="Telicka"


******************************************************************************
* EXPLORATIVE DATA ANALYSIS
******************************************************************************

*** LIST FORMER POSITIONS (AND SCORE) OF PRESIDENTS OVER TIME
sort time
list name highestpos posscore if president==1
display "SHOWN AS TABLE IN PAPER"

*** GRAPH FORMER POSITIONS(SCORE) OF PRESIDENTS OVER TIME
line posscore time if president==1
graph export output/regression-time-president.png ,replace
display "GRAPH SAVED IN SUBFOLDER 'GRAPHS'"

*** TABLE OF MEAN POSITION SCORE FOR ALL COMMISSIONS
tabulate commission, sum (posscore)
tabulate commission, sum (posscore), if incumbent==0

*** BOX PLOT POSITION SCORE FOR COMMISSIONS
graph box posscore, over (commission)
graph box posscore, over (commission), if(incumbent == 0)

*** PARTY AFFILLIATION FOR SMALL AND LARGE MEMBER STATES 
*** (OUTPUT NOT SHOWN IF 'QUIETLY' IS SET)
quietly bysort country (time): list commission partygov incumbent party if oneseat==1
quietly bysort country (time): list commission partygov incumbent party if oneseat==0

*** TABLE SUMMARIZING COMMISSIONERS PARTY AFFILLIATIONS 
tabulate partygov oneseat, freq 
tabulate partygov oneseat if incumbent==1, freq 
display "SHOWN AS ONE TABLE IN PAPER"


******************************************************************************
* OLS-REGRESSION
******************************************************************************

*** MAJOR OLS-MODEL
regress posscore time incumbent oneseat
outreg using output/regression-table.rtf, replace
* type output/regression-table.rtf
display "SHOWN AS TABLE IN PAPER"

*** MODEL ROBUSTNESS FOR FOUNDING MEMBERS
regress  posscore time incumbent oneseat if country < 7

*** MODEL ROBUSTNESS BEFORE CENTRAL/EASTERN EUROPEAN ENLARGEMENT
*** AND WITHOUT THE NEW STATES (ONLY ONE OBSERVATION)
regress  posscore time incumbent oneseat if commission !=13
regress  posscore time incumbent oneseat if country < 16

*** MODEL ROBUSTNESS WHILE DROPPING VARIABLES
regress  posscore time  oneseat
regress  posscore time incumbent
regress  posscore time

*** MODEL ROBUSTNESS WITH DUMMY VARIABLES FOR COMMISSIONS
xi: regress posscore incumbent oneseat I.commission
*** MODEL ROBUSTNESS WITH DUMMY VARIABLES FOR COUNTRIES
xi: regress posscore time incumbent oneseat
*** (ONLY FOR FOUNDING MEMBERS AND COUNTRIES OF FIRST ENLARGEMENT)
xi: regress posscore time incumbent oneseat I.country if country < 10

*** TESTING MODEL WITHOUT MOST OF THE SELF ASSIGNED VALUES 
*** FOR MP, MEP, DIPLOMATS, BUREAUCRATS (ONLY DRUCKMAN SCORES)
regress posscore time incumbent oneseat if posscore > .34

*** TESTING FOR INTERACTION EFFECTS
gen timeincumbent =time*incumbent 
gen timeoneseat =time*oneseat 
regress posscore time incumbent oneseat timeincumbent timeoneseat
drop timeincumbent
drop timeoneseat


******************************************************************************
* MULTIPLE LOGIT Model
******************************************************************************
/*
 as an alternative, scale based data (posscore) is transformed 
 into categorial data (positiongroups)
  0 = mp, mep, diplomats, bureaucrats, non-political carreer
  1 = junior ministers and low level ministers
  2 = ministers
  3 = top ministers (prime minister, foreign affairs, finance)
*/
capture egen positiongroup = cut(posscore), at(0,.34,.89,1.24,3) icodes

*** TABLE FOR FREQUENCIES OF POSITIONS (GROUPS)
tabulate positiongroup

*** TABLE FOR FREQUENCIES OF POSITIONS IN CERTAIN PERIODS
*** 1958--73 (0) 1973--85 (5) 1985--95 (8) 1995--05 (11)
capture egen commissiongroup=cut(commission), at (0,5,8,11,14)
tabulate positiongroup commissiongroup
bysort oneseat: tabulate positiongroup commissiongroup if country < 10 & commission != 13
drop commissiongroup

*** TABLE FOR FREQUENCIES OF POLITICAL POSITIONS
tabulate elected commission

*** LOGIT MODEL BASED ON POSITION CATEGORIES
mlogit positiongroup time incumbent oneseat
mlogit positiongroup time incumbent oneseat, basecategory(2) 

*** MODEL ROBUSTNESS BEFORE CENTRAL/EASTERN EUROPEAN ENLARGEMENT 
mlogit positiongroup time incumbent oneseat if commission !=13
*** MODEL ROBUSTNESS WITHOUT CENTRAL/EASTERN EUROPEAN STATES (ONE OBSERVATION)
mlogit positiongroup time incumbent oneseat if country < 16

drop positiongroup


******************************************************************************
* MODEL TO TEST HOW MANY COMMISSIONERS HELD NO POLITICAL POSITION BEFORE
******************************************************************************

logit elected time incumbent oneseat
logistic elected time incumbent oneseat

capture outreg using output/regression-table.rtf, append
* type output/regression-table.rtf
display "SHOWN AS TABLE IN PAPER"

fitstat
* prtab time oneseat , rest(min)
display "TABLE SHOWN IN PAPER"

*** TEST IF INCLUSION OF CATEGORY FOR ONE SEAT / INCUMBENTS INCREASES PERFORMANCE OF MODEL
capture gen oneseatincumbent = oneseat * incumbent 
logit elected time incumbent oneseat oneseatincumbent
fitstat


*** MODEL INFLUENCE ON INCUMBENT STATUS
logit incumbent time partygov oneseat if partygov !=2
fitstat


******************************************************************************
* PARTY GOVERNMENT RELATIONS OF COMMISSIONER
******************************************************************************

*** EXPLORATIVE DATA ANALYSIS

*** TABLE FOR FREQUENCIES OF COMMISSIONERS PARTY AFFILLIATION
tab partygov commission
tab partygov commission if oneseat == 0
tab partygov commission if oneseat == 1

*** MULTIVARIATE ANALYSIS

*** MULTIPLE LOGIT MODEL INCLUDING COMMISSIONERS WITHOUT PARTY AFFILLIATION
capture gen oneseatincumbent = oneseat * incumbent 
mlogit  partygov time incumbent oneseat oneseatincumbent

capture outreg using output/regression-table.rtf, append
* type output/regression-table.rtf
display "SHOWN AS TABLE IN PAPER"

fitstat
* prtab oneseat oneseatincumbent , x(time=22) rest(min)
* prchange, x(oneseatincumbent=1 time=mean) rest(min)
mlogit  partygov time incumbent oneseat oneseatincumbent if commission !=13
display "SHOWN AS TABLE IN PAPER"


******************************************************************************
* CLEANING UP
******************************************************************************
clear
* erase output/regression-table.rtf
set more on
log close


